
#include <iostream>

#include <error_code.hpp>

typedef boost::system::error_code error_code;

error_code validate(char *, error_code &ec)
{
	if(ec)
	{
		ec = error_code();
	}
	else
	{
		ec = xbase::error::header_incomplete;
	}
	return ec;
}

int main()
{
	boost::system::error_code ok;
	boost::system::error_code xbase_error = xbase::error::bad_magic;
	boost::system::error_code xbase_error_2 = xbase::error::make_error_code(xbase::error::bad_magic);

	assert(xbase_error_2 == xbase_error);
	assert(ok != xbase_error);

	ok = xbase_error;
	assert(ok == xbase_error);

	error_code ok_2;

	validate(NULL, xbase_error_2);
	assert(xbase_error_2 == ok_2);
	
	validate(NULL, ok_2);
	assert(ok_2 == xbase::error::header_incomplete);

	std::cout << xbase_error << " - " << xbase_error.message() << std::endl;
	std::cout << xbase::error::bad_magic << std::endl;
}
